
//////////////////////////////////////////////////
/// "From Low-Cost Flights to the Ballot Box:  ///
///   How Eastern European Migration Shaped    ///
///        Far-Right Voting in London"         ///
///      By Elena Pupaza & Joachim Wehner      ///
///          The Journal of Politics           ///
//////////////////////////////////////////////////

* Replication do file (online appendix figures on London airports)
* Prepared with Stata/SE 17.0 for Mac
* November 17, 2022

* List of figures in chronological order (online appendix):
* Figure B.2: Number of EU8+2 destinations by London airport, 2001-2014
* Figure B.3: Passenger traffic to/from EU8+2 countries by London airport, 2001-2014
* Figure B.4: Total number of passengers to/from London and EU8/EU2 countries, 2001- 2014
* Figure D.1: Monthly total number of passengers to/from London and EU8/EU2 countries, 2004

* Data sources:
* Civil Aviation Authority. 2020. "International Air Passenger Traffic To and From UK Reporting Airports" [Computer file].
* www.caa.co.uk/Data-and-analysis/UK-aviation-market/Airports/Datasets/UK- Airport-data/Airport-data-1990-onwards/
* Figures B.2 to B.4 use annual data from Table 12.1, downloaded on December 28, 2020.
* Figure D.1 uses monthly data from Table 12.1, downloaded on February 6, 2021.


*******************
*** Annual data ***
*******************

* For use with data file "Pupaza & Wehner_Airports_Annual.dta"

set more off

gen EU8 = 0
replace EU8 = 1 if inlist(foreign_country, "ESTONIA", "LATVIA", "LITHUANIA", "CZECH REPUBLIC", "HUNGARY", "POLAND", "SLOVAK REPUBLIC", "SLOVENIA" )

gen EU2 = 0
replace EU2 = 1 if inlist(foreign_country, "BULGARIA", "ROMANIA")

gen EU10 = 0
replace EU10 = 1 if EU8 == 1 | EU2 == 1

gen luton = 0
replace luton = 1 if uk_apt == "LUTON"

gen stansted = 0
replace stansted = 1 if uk_apt == "STANSTED"

gen london_apt = 0
replace london_apt = 1 if inlist(uk_apt, "LUTON", "HEATHROW", "STANSTED", "LONDON CITY", "GATWICK", "SOUTHEND")

sort report_period
by report_period: egen london_total = sum(ty_t_pax) if london_apt == 1
by report_period: egen EU8_london_total = sum(ty_t_pax) if EU8 == 1 & london_apt == 1
by report_period: egen EU2_london_total = sum(ty_t_pax) if EU2 == 1 & london_apt == 1
by report_period: egen EU10_london_total = sum(ty_t_pax) if EU10 == 1 & london_apt == 1
by report_period: egen EU10_luton_total = sum(ty_t_pax) if EU10 == 1 & luton == 1
by report_period: egen EU10_stansted_total = sum(ty_t_pax) if EU10 == 1 & stansted == 1
by report_period: egen EU10_heathrow_total = sum(ty_t_pax) if EU10 == 1 & uk_apt == "HEATHROW"
by report_period: egen EU10_city_total = sum(ty_t_pax) if EU10 == 1 & uk_apt == "LONDON CITY"
by report_period: egen EU10_gatwick_total = sum(ty_t_pax) if EU10 == 1 & uk_apt == "GATWICK"
by report_period: egen EU10_southend_total = sum(ty_t_pax) if EU10 == 1 & uk_apt == "SOUTHEND"

gen london_total_mio = london_total / 1000000
gen EU8_london_total_mio = EU8_london_total / 1000000
gen EU2_london_total_mio = EU2_london_total / 1000000
gen EU10_london_total_mio = EU10_london_total / 1000000

gen EU10_luton_total_mio = EU10_luton_total / 1000000
gen EU10_stansted_total_mio = EU10_stansted_total / 1000000
gen EU10_heathrow_total_mio = EU10_heathrow_total / 1000000
gen EU10_city_total_mio = EU10_city_total / 1000000
gen EU10_gatwick_total_mio = EU10_gatwick_total / 1000000
gen EU10_southend_total_mio = EU10_southend_total / 1000000

sort uk_apt
by uk_apt: gen EU10_luton_share2 = EU10_luton_total / EU10_london_total
by uk_apt: gen EU10_stansted_share2 = EU10_stansted_total / EU10_london_total

sort report_period
by report_period: egen EU10_luton_share = mean(EU10_luton_share2)
by report_period: egen EU10_stansted_share = mean(EU10_stansted_share2)

sort report_period uk_apt
list report_period uk_apt EU10_luton_share EU10_luton_share2 if EU10_luton_share2 ~= .
list report_period uk_apt EU10_stansted_share EU10_stansted_share2 if EU10_stansted_share2 ~= .
drop EU10_luton_share2 EU10_stansted_share2

sort report_period uk_apt
by report_period uk_apt: gen destinations = _N
gen destinations_luton = destinations if uk_apt == "LUTON"
gen destinations_stansted = destinations if uk_apt == "STANSTED"
gen destinations_heathrow = destinations if uk_apt == "HEATHROW"
gen destinations_gatwick = destinations if uk_apt == "GATWICK"
gen destinations_city = destinations if uk_apt == "LONDON CITY"
gen destinations_southend = destinations if uk_apt == "SOUTHEND"

sort report_period uk_apt EU10
by report_period uk_apt EU10: gen destinations_EU10_luton = _N if uk_apt == "LUTON" & EU10 == 1
by report_period uk_apt EU10: gen destinations_EU10_stansted = _N if uk_apt == "STANSTED" & EU10 == 1
by report_period uk_apt EU10: gen destinations_EU10_heathrow = _N if uk_apt == "HEATHROW" & EU10 == 1
by report_period uk_apt EU10: gen destinations_EU10_gatwick = _N if uk_apt == "GATWICK" & EU10 == 1
by report_period uk_apt EU10: gen destinations_EU10_city = _N if uk_apt == "LONDON CITY" & EU10 == 1
by report_period uk_apt EU10: gen destinations_EU10_southend = _N if uk_apt == "SOUTHEND" & EU10 == 1

linepalette default


*** Figure B.2: Number of EU8+2 destinations by London airport, 2001-2014

graph twoway ///
(line destinations_EU10_luton report_period, lpattern(longdash_shortdash) lcolor("200 0 0") lwidth(medium)) ///
(line destinations_EU10_stansted report_period, lpattern(solid) lcolor("64 105 166") lwidth(medium)) ///
(line destinations_EU10_gatwick report_period, lpattern(dash) lcolor(gs7)) ///
(line destinations_EU10_heathrow report_period, lpattern(shortdash) lcolor(gs7)) ///
(line destinations_EU10_city report_period, lpattern(longdash) lcolor(gs7)) ///
(line destinations_EU10_southend report_period, lpattern(dot) lcolor(gs7)), ///
ylabel(0 5 10 15 20 25 30 35, labsize(medsmall) nogrid) ///
xlabel(2000 2005 2010 2015, labsize(medsmall) nogrid) ///
plotregion(color(white) lwidth(medium) lcolor(black)) ///
ytitle("Number of EU8+2 destinations", size(3.5) height(5)) ///
xtitle("") ///
graphregion(color(white)) xsize(1.75) ysize(1) ///
legend(label(1 "Luton") label(2 "Stansted") label(3 "Gatwick") label(4 "Heathrow") ///
label(5 "City") label(6 "Southend") cols(1) ring(0) position(10) bmargin(medium)) ///
name(air_destinations, replace)


* Figure B.3: Passenger traffic to/from EU8+2 countries by London airport, 2001-2014

graph twoway ///
(line EU10_luton_total_mio report_period, lpattern(longdash_shortdash) lcolor("200 0 0") lwidth(medium)) ///
(line EU10_stansted_total_mio report_period, lpattern(solid) lcolor("64 105 166") lwidth(medium)) ///
(line EU10_gatwick_total_mio report_period, lpattern(dash) lcolor(gs7)) ///
(line EU10_heathrow_total_mio report_period, lpattern(shortdash) lcolor(gs7)) ///
(line EU10_city_total_mio report_period, lpattern(longdash) lcolor(gs7)) ///
(line EU10_southend_total_mio report_period, lpattern(dot) lcolor(gs7)), ///
ylabel(0 1 2 3 4, labsize(medsmall) nogrid) ///
xlabel(2000 2005 2010 2015, labsize(medsmall) nogrid) ///
plotregion(color(white) lwidth(medium) lcolor(black)) ///
ytitle("EU8+2 air passenger traffic (millions)", size(3.5) height(5)) ///
xtitle("") ///
graphregion(color(white)) xsize(1.75) ysize(1) ///
legend(label(1 "Luton") label(2 "Stansted") label(3 "Gatwick") label(4 "Heathrow") ///
label(5 "City") label(6 "Southend") cols(1) ring(0) position(10) bmargin(medium)) ///
name(air_totals_byairport, replace)


* Figure B.4: Total number of passengers to/from London and EU8/EU2 countries, 2001- 2014

graph twoway ///
(line EU8_london_total_mio report_period, lpattern(solid) lcolor("64 105 166") lwidth(medium)) ///
(line EU2_london_total_mio report_period, lpattern(dash) lcolor("200 0 0") lwidth(medium)), ///
ylabel(0 1 2 3 4 5 6 7 8, labsize(medsmall) nogrid) ///
xlabel(2000 2005 2010 2015, labsize(medsmall) nogrid) ///
plotregion(color(white) lwidth(medium) lcolor(black)) ///
ytitle("EU8+2 London air passenger traffic (millions)", size(3.5) height(5)) ///
xtitle("") ///
graphregion(color(white)) xsize(1.75) ysize(1) ///
legend(label(1 "EU8") label(2 "EU2") ///
cols(1) ring(0) position(10) bmargin(medium)) ///
name(air_totals, replace)

clear


********************
*** Monthly data ***
********************

* For use with data file "Pupaza & Wehner_Airports_Monthly.dta"

set more off

gen month = mod(reporting_period,100)

gen EU8 = 0
replace EU8 = 1 if inlist(foreign_country, "ESTONIA", "LATVIA", "LITHUANIA", "CZECH REPUBLIC", "HUNGARY", "POLAND", "SLOVAK REPUBLIC", "SLOVENIA" )

gen EU2 = 0
replace EU2 = 1 if inlist(foreign_country, "BULGARIA", "ROMANIA")

gen EU10 = 0
replace EU10 = 1 if EU8 == 1 | EU2 == 1

gen luton = 0
replace luton = 1 if uk_airport == "LUTON"

gen stansted = 0
replace stansted = 1 if uk_airport == "STANSTED"

gen london_apt = 0
replace london_apt = 1 if inlist(uk_airport, "LUTON", "HEATHROW", "STANSTED", "LONDON CITY", "GATWICK", "SOUTHEND")

sort reporting_period
by reporting_period: egen london_total = sum(this_month_total_pax) if london_apt == 1
by reporting_period: egen EU8_london_total = sum(this_month_total_pax) if EU8 == 1 & london_apt == 1
by reporting_period: egen EU2_london_total = sum(this_month_total_pax) if EU2 == 1 & london_apt == 1
by reporting_period: egen EU10_london_total = sum(this_month_total_pax) if EU10 == 1 & london_apt == 1
by reporting_period: egen EU10_luton_total = sum(this_month_total_pax) if EU10 == 1 & luton == 1
by reporting_period: egen EU10_stansted_total = sum(this_month_total_pax) if EU10 == 1 & stansted == 1
by reporting_period: egen EU10_heathrow_total = sum(this_month_total_pax) if EU10 == 1 & uk_airport == "HEATHROW"
by reporting_period: egen EU10_city_total = sum(this_month_total_pax) if EU10 == 1 & uk_airport == "LONDON CITY"
by reporting_period: egen EU10_gatwick_total = sum(this_month_total_pax) if EU10 == 1 & uk_airport == "GATWICK"
by reporting_period: egen EU10_southend_total = sum(this_month_total_pax) if EU10 == 1 & uk_airport == "SOUTHEND"

gen london_total_thousands = london_total / 1000
gen EU8_london_total_thousands = EU8_london_total / 1000
gen EU2_london_total_thousands = EU2_london_total / 1000
gen EU10_london_total_thousands = EU10_london_total / 1000

gen EU10_luton_total_thousands = EU10_luton_total / 1000
gen EU10_stansted_total_thousands = EU10_stansted_total / 1000
gen EU10_heathrow_total_thousands = EU10_heathrow_total / 1000
gen EU10_city_total_thousands = EU10_city_total / 1000
gen EU10_gatwick_total_thousands = EU10_gatwick_total / 1000
gen EU10_southend_total_thousands = EU10_southend_total / 1000


*** Figure D.1: Monthly total number of passengers to/from London and EU8/EU2 countries, 2004

graph twoway ///
(line EU8_london_total_thousands month, lpattern(solid) lcolor("64 105 166") lwidth(medium)) ///
(line EU2_london_total_thousands month, lpattern(dash) lcolor("200 0 0") lwidth(medium)), ///
ylabel(0 50 100 150 200 250 300 350 400, labsize(medsmall) nogrid) ///
xlabel(1 2 3 4 5 6 7 8 9 10 11 12, labsize(medsmall) nogrid) ///
plotregion(color(white) lwidth(medium) lcolor(black)) ///
ytitle("EU8+2 London air passenger traffic (thousands)", size(3.5) height(5)) ///
xtitle("Month") ///
graphregion(color(white)) xsize(1.75) ysize(1) ///
legend(label(1 "EU8") label(2 "EU2") ///
cols(1) ring(0) position(10) bmargin(medium)) ///
name(air_totals_2004, replace)
